package com.qfedu.knowledge.controller;


import com.qfedu.knowledge.entity.bo.UserBO;
import com.qfedu.knowledge.entity.dto.BasePageDTO;
import com.qfedu.knowledge.entity.vo.ResultVO;
import com.qfedu.knowledge.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserController
 * @Author ykx
 * @Date 2024/4/18 21:15
 * @Version 1.0
 */
@RestController
@RequestMapping(value = "/knowledge")
public class UserController {

    @Autowired
    private IUserService userService;

    @GetMapping("/user/list")
    public ResultVO getUserList(BasePageDTO basePageDTO) {
        return ResultVO.success(userService.getUserList(basePageDTO));
    }

    @PostMapping("/user/save")
    public ResultVO save(@RequestBody UserBO userBO) {
        return ResultVO.success(userService.saveOrUpdate(userBO));
    }

    @PutMapping("/user/{id}")
    public ResultVO update(@PathVariable("id") Long id, @RequestBody UserBO userBO) {
        userBO.setId(id);
        return ResultVO.success(userService.saveOrUpdate(userBO));
    }

    @DeleteMapping("/user/delete/{id}")
    public ResultVO delete(@PathVariable("id") Integer id) {
        return ResultVO.success(userService.removeById(id));
    }

}
